﻿#region codejockey.net Copyright Banner
/***************************************************************\
 * Copyright 2010 codejockey.net.                                *
 *                                                               *
 * This code is property of codejockey.net and cannot be used    *
 * without explicit permission given by a codejockey.net         *
 * Representative.  For details contact: source@codejockey.net   *
 \***************************************************************/
#endregion

using System;
using codejockey.Shared.Text.ReplacementTokens;

namespace codejockey.BingPaper.Utils.ReplacementTokens
{
  public class MonthReplacementToken : FormatStringReplacmentTokenBase
  {

    #region Private Fields

    private const string TokenText = "$month$";
    private const string TokenName = "MonthReplacementToken";
    private const string TokenDescription = "The MontReplacementToken provides for the current month.";

    #endregion

    #region Constructors

    public MonthReplacementToken(string formatString)
    {
      FormatString = formatString;
    }

    #endregion

    #region Public Methods

    public override string GetName()
    {
      return TokenName;
    }

    public override string GetDescription()
    {
      return TokenDescription;
    }

    public override string GetToken()
    {
      return TokenText;
    }

    public override string Replace(string tokenizedString)
    {
      tokenizedString = base.Replace(tokenizedString);

      if (tokenizedString.Contains(Token))
      {
        string monthString = string.Format(FormatString, DateTime.Now.Month);
        tokenizedString = tokenizedString.Replace(Token, monthString);
        Processed = true;
      }

      return tokenizedString;
    }

    #endregion

  }
}
